home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / vcredit / vidbjcts.c < prev   
Encoding:
C/C++ Source or Header  |  1993-06-15  |  12.6 KB  |  567 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/vcrEdit/RCS/videoObjects.c,v 0.25 93/02/07 12:59:38 drapeau Exp $ */
  25. /* $Log:    videoObjects.c,v $
  26.  * Revision 0.25  93/02/07  12:59:38  drapeau
  27.  * Fixed minor error in communications specifications for Sony1550 driver.
  28.  * 
  29.  * Revision 0.24  92/11/17  14:43:59  drapeau
  30.  * Corrected errors in configuration of several devices, especially the
  31.  * Pioneer4200 player.
  32.  * 
  33.  * Revision 0.23  92/10/01  17:14:25  drapeau
  34.  * Updated the Config structures for several of the devices supported by the
  35.  * VideoObject library, to reflect improvements in the library's serial line
  36.  * driver code.
  37.  * 
  38.  * Revision 0.22  92/09/04  17:08:49  drapeau
  39.  * Updated file to account for changes in serial line communications.
  40.  * 
  41.  * Revision 1.14  92/09/03  10:25:12  drapeau
  42.  * Changed communications settings for the NEC driver configuration.
  43.  * 
  44.  * Revision 1.13  92/09/02  17:14:04  drapeau
  45.  * Modified device-specific Config structs to reflect the addition of a
  46.  * new field, "flowControl".
  47.  * 
  48.  * Revision 1.12  92/09/01  16:58:56  drapeau
  49.  * A couple of changes:
  50.  * * Updated copyright notice.
  51.  * * Updated default Config structures to reflect new methods added to the
  52.  *   VideoObject.
  53.  * * Cosmetic changes to make code easier to read.
  54.  * * Added function prototypes for better ANSI compliance.
  55.  * 
  56.  * Revision 1.11  92/07/30  15:15:57  drapeau
  57.  * Improved method for setting asynchronous read function.  The previous
  58.  * version, although designed to be independent of any window system or
  59.  * programming toolkit, was still too reliant on the XView toolkit.  This
  60.  * error no longer exists.
  61.  * Also, minor change to PrintDiagnostics() function; it no longer
  62.  * explicitly terminates with a "\n"; the caller must decide that a
  63.  * "\n" is wanted at the end of the string.
  64.  * 
  65.  * Revision 1.10  92/06/16  23:49:15  drapeau
  66.  * Made a number of changes:
  67.  * * Added support for the Sony CVD1000 (aka "Vdeck") device.
  68.  * * Added 'SetAsynchReadFunction' so as to allow the use of generic toolkit
  69.  *   notify functions for file reads.  This is the first step toward making
  70.  *   the VideoObject toolkit-neutral.
  71.  * 
  72.  * Revision 1.0  91/11/15  17:38:28  collab
  73.  * Initial revision
  74.  * 
  75.  * Revision 0.18  91/09/29  16:12:47  lim
  76.  * Put in all drivers.
  77.  * Added DisplayChoice.
  78.  * 
  79.  * Revision 0.17  91/09/24  22:01:29  lim
  80.  * 1. Used relative filename for driver header file.
  81.  * 
  82.  * Revision 0.16  91/08/24  18:00:57  lim
  83.  * Implemented PrintDiagnostics.
  84.  * 
  85.  * Revision 0.15  91/08/23  17:24:48  lim
  86.  * Included NECDriver.h
  87.  * Clear Marker has been removed as one of the video
  88.  * object functions.
  89.  * 
  90.  * Revision 0.14  91/08/21  10:52:54  lim
  91.  * Added second parameter to DevInit(serialPort).
  92.  * 
  93.  * Revision 0.13  91/08/17  20:45:50  lim
  94.  * 1. Configuration no longer has field for 'interruptibleSegmentPlay'.
  95.  * 2. NECInterrupt becomes NECClearMarker.
  96.  * 
  97.  * Revision 0.12  91/08/15  13:04:51  lim
  98.  * *** empty log message ***
  99.  * 
  100.  * Revision 0.11  91/08/09  11:05:29  lim
  101.  * Moved 'NECDriver.h' from 'vcrEdit.h'
  102.  * 
  103.  * Revision 0.10  91/08/08  17:32:34  lim
  104.  * Initial revision.
  105.  * 
  106.  * Revision 0.11  91/08/07  13:33:39  lim
  107.  * 1. DevInit() now returns pointer to VideoObject.
  108.  * 2. Added instance pointer, "theObject" to all public function calls.
  109.  * 3. DisplayError() is added so that device drivers can call it to 
  110.  * display error messages.
  111.  * 
  112.  * Revision 0.10  91/08/02  12:45:00  lim
  113.  * Initial revision.
  114.  *  */
  115.  
  116. /* WRITING NEW APPLICATION...
  117.  * 1. Replace the header file below with the header file for your own application.
  118.  */
  119.  
  120. #include "vcrEdit.h"
  121. #include <Pioneer4200Driver.h>
  122. #include <PanasonicOptDriver.h>
  123. #include <Pioneer6000Driver.h>
  124. #include <Sony1550Driver.h>
  125. #include <NECDriver.h>
  126. #include <CVD1000Driver.h>
  127.  
  128. /* ADDING NEW DRIVERS...
  129.  * 1. Add name of player to the array below.
  130.  * 2. Increment 'numDevices'.
  131.  */
  132.  
  133. char allDevices[MaxDevices][MaxNameLength]= 
  134. {
  135.   "Pioneer4200",
  136.   "Pioneer6000",
  137.   "Panasonic2026",
  138.   "Sony1550",
  139.   "NEC",
  140.   "CVD1000"
  141.   }
  142. ;
  143. int numDevices = 6;
  144.  
  145.  
  146. /* INCLUDE VIDEO OBJECTS HERE */
  147.  
  148.  
  149. /* Video Object for Pioneer4200 */
  150.  
  151. static Config Pioneer4200Config = 
  152. {
  153.   "Pioneer4200",
  154.   "/dev/ttya",
  155.   4800,
  156.   13,
  157.   8,
  158.   NoParity,
  159.   No,
  160.   No,
  161.   120,
  162.   -1
  163.   }
  164. ;
  165.  
  166. static VideoObject Pioneer4200Obj = 
  167. {
  168.   &Pioneer4200Config,
  169.   Pioneer4200Play,
  170.   Pioneer4200PlayFromTo,
  171.   Pioneer4200FastForward,
  172.   Pioneer4200Reverse,
  173.   Pioneer4200CalcSpeed,
  174.   Pioneer4200PlayAtSpeedDir,
  175.   Pioneer4200Step,
  176.   Pioneer4200Still,
  177.   Pioneer4200Stop,
  178.   Pioneer4200SetDefaults,
  179.   Pioneer4200SetAudio,
  180.   Pioneer4200SetVideo,
  181.   Pioneer4200SetAddMode,
  182.   Pioneer4200SetAddressDisplay,
  183.   Pioneer4200Eject,
  184.   Pioneer4200Power,
  185.   Pioneer4200QueryFrame,
  186.   Pioneer4200QueryChapter,
  187.   Pioneer4200QueryAudio,
  188.   Pioneer4200QueryVideo,
  189.   Pioneer4200QueryMedium,
  190.   Pioneer4200QueryStatus, 
  191.   Pioneer4200Ping,
  192.   NULL,
  193.   NULL
  194.   }
  195. ;
  196.  
  197. /* Video Object for CVD1000 */
  198.  
  199. static Config CVD1000Config = 
  200. {
  201.   "CVD1000",
  202.   "/dev/ttya",
  203.   9600,
  204.   -1,
  205.   8,
  206.   NoParity,
  207.   No,
  208.   No,
  209.   60,
  210.   -1
  211.   }
  212. ;
  213.  
  214. static VideoObject CVD1000Obj = 
  215. {
  216.   &CVD1000Config,
  217.   CVD1000Play,
  218.   CVD1000PlayFromTo,
  219.   CVD1000FastForward,
  220.   CVD1000Reverse,
  221.   CVD1000CalcSpeed,
  222.   CVD1000PlayAtSpeedDir,
  223.   CVD1000Step,
  224.   CVD1000Still,
  225.   CVD1000Stop,
  226.   CVD1000SetDefaults,
  227.   CVD1000SetAudio,
  228.   CVD1000SetVideo,
  229.   CVD1000SetAddMode,
  230.   CVD1000SetAddressDisplay,
  231.   CVD1000Eject,
  232.   CVD1000Power,
  233.   CVD1000QueryFrame,
  234.   CVD1000QueryChapter,
  235.   CVD1000QueryAudio,
  236.   CVD1000QueryVideo,
  237.   CVD1000QueryMedium,
  238.   CVD1000QueryStatus, 
  239.   CVD1000Ping,
  240.   CVD1000Record,
  241.   CVD1000RecordFromTo
  242.   }
  243. ;
  244.  
  245. /* Video Object for PanasonicOpticalDiskPlayer */
  246.  
  247. static Config PanasonicOptConfig = 
  248. {
  249.   "Panasonic2026",
  250.   "/dev/ttyb",
  251.   9600,
  252.   13,
  253.   8,
  254.   NoParity,
  255.   No,
  256.   No,
  257.   300, 
  258.   -1
  259.   }
  260. ;
  261.  
  262. static VideoObject PanasonicOptObj = 
  263. {
  264.   &PanasonicOptConfig,
  265.   PanasonicOptPlay,
  266.   PanasonicOptPlayFromTo,
  267.   PanasonicOptFastForward,
  268.   PanasonicOptReverse,
  269.   PanasonicOptCalcSpeed,
  270.   PanasonicOptPlayAtSpeedDir,
  271.   PanasonicOptStep,
  272.   PanasonicOptStill,
  273.   PanasonicOptStop,                            
  274.   PanasonicOptSetDefaults,                        
  275.   PanasonicOptSetAudio,                        
  276.   PanasonicOptSetVideo,
  277.   NULL,
  278.   PanasonicOptSetAddressDisplay,
  279.   PanasonicOptEject,
  280.   NULL,
  281.   PanasonicOptQueryFrame,
  282.   NULL,
  283.   NULL,
  284.   NULL,
  285.   PanasonicOptQueryMedium,
  286.   PanasonicOptQueryStatus,
  287.   PanasonicOptPing,
  288.   NULL,
  289.   NULL
  290.   }
  291. ;
  292.  
  293. /* Video Object for Pioneer6000 */
  294.  
  295. static Config Pioneer6000Config = 
  296. {
  297.   "Pioneer6000",
  298.   "/dev/ttyb",
  299.   9600,
  300.   13,
  301.   8,
  302.   NoParity,
  303.   No,
  304.   No,
  305.   90,
  306.   -1
  307.   }
  308. ;
  309.  
  310. static VideoObject Pioneer6000Obj = 
  311. {
  312.   &Pioneer6000Config,
  313.   Pioneer6000Play,
  314.   Pioneer6000PlayFromTo,
  315.   Pioneer6000FastForward,
  316.   Pioneer6000Reverse,
  317.   Pioneer6000CalcSpeed,
  318.   Pioneer6000PlayAtSpeedDir,
  319.   Pioneer6000Step,
  320.   Pioneer6000Still,
  321.   Pioneer6000Stop,                            
  322.   Pioneer6000SetDefaults,                        
  323.   Pioneer6000SetAudio,                        
  324.   Pioneer6000SetVideo,
  325.   NULL,
  326.   Pioneer6000SetAddressDisplay,
  327.   Pioneer6000Eject,
  328.   NULL,
  329.   Pioneer6000QueryFrame,
  330.   NULL,
  331.   NULL,
  332.   NULL,
  333.   NULL,
  334.   Pioneer6000QueryStatus,
  335.   Pioneer6000Ping,
  336.   NULL,
  337.   NULL
  338.   }
  339. ;
  340.  
  341. /* Video Object for Sony1550 */
  342.  
  343. static Config Sony1550Config = 
  344. {
  345.   "Sony1550",
  346.   "/dev/ttyb",
  347.   1200,
  348.   -1,
  349.   8,
  350.   NoParity,
  351.   Yes,
  352.   No,
  353.   90,
  354.   -1
  355.   }
  356. ;
  357.  
  358. static VideoObject Sony1550Obj = 
  359. {
  360.   &Sony1550Config,
  361.   Sony1550Play,
  362.   Sony1550PlayFromTo,
  363.   Sony1550FastForward,
  364.   Sony1550Reverse,
  365.   Sony1550CalcSpeed,
  366.   Sony1550PlayAtSpeedDir,
  367.   Sony1550Step,
  368.   Sony1550Still,
  369.   Sony1550Stop,                            
  370.   Sony1550SetDefaults,                        
  371.   Sony1550SetAudio,                        
  372.   Sony1550SetVideo,
  373.   Sony1550SetAddMode,
  374.   Sony1550SetAddressDisplay,
  375.   Sony1550Eject,
  376.   NULL,
  377.   Sony1550QueryFrame,
  378.   Sony1550QueryChapter,
  379.   NULL,
  380.   NULL,
  381.   Sony1550QueryMedium,
  382.   Sony1550QueryStatus,
  383.   Sony1550Ping,
  384.   NULL,
  385.   NULL
  386.   }
  387. ;
  388.  
  389.  
  390. /* Video Object for NEC PC VCR */
  391.  
  392. static Config NECConfig = 
  393. {
  394.   "NEC",
  395.   "/dev/ttya",
  396.   1200,
  397.   13,
  398.   8,
  399.   NoParity,
  400.   No,
  401.   No,
  402.   270,
  403.   -1
  404.   }
  405. ;
  406.  
  407. static VideoObject NECObj = 
  408. {
  409.   &NECConfig,
  410.   NECPlay,
  411.   NECPlayFromTo,
  412.   NECFastForward,
  413.   NECReverse,
  414.   NECCalcSpeed,
  415.   NECPlayAtSpeedDir,
  416.   NECStep,
  417.   NECStill,
  418.   NECStop,
  419.   NECSetDefaults,
  420.   NECSetAudio,
  421.   NECSetVideo,
  422.   NECSetAddressingMode,
  423.   NULL,
  424.   NECEject,
  425.   NECPower,
  426.   NECQueryFrame,
  427.   NULL,
  428.   NECQueryAudio,
  429.   NECQueryVideo,
  430.   NECReadHeader,
  431.   NECQueryStatus,
  432.   NECPing,
  433.   NECRecord,
  434.   NECRecordFromTo
  435.   }
  436. ;
  437.  
  438.  
  439. /* DevInit builds the video object for the appropriate ...
  440.  * ... device and sets up the serial line.  It returns the ...
  441.  * ... pointer to the video object.
  442.  */
  443.  
  444. VideoObject*
  445.   DevInit(char*    deviceName,
  446.       char* serialPort)
  447. {
  448.   VideoObject* myVideo;
  449.   
  450.   /* ADDING NEW DRIVERS
  451.      ... Add statements for new device here, as another else-if statement */
  452.   
  453.   if (strcmp(deviceName, "Pioneer4200") == 0)                /* Set the video object to the appropriate variable */
  454.     myVideo = BuildVideoObject(&Pioneer4200Obj);
  455.   else if (strcmp(deviceName, "Sony1550") == 0)
  456.     myVideo = BuildVideoObject(&Sony1550Obj);
  457.   else if (strcmp(deviceName, "Panasonic2026") == 0)
  458.     myVideo = BuildVideoObject(&PanasonicOptObj);
  459.   else if (strcmp(deviceName, "Pioneer6000") == 0)
  460.     myVideo = BuildVideoObject(&Pioneer6000Obj);
  461.   else if (strcmp(deviceName, "NEC") == 0)
  462.     myVideo = BuildVideoObject(&NECObj);                
  463.   else if (strcmp(deviceName, "CVD1000") == 0)
  464.     myVideo = BuildVideoObject(&CVD1000Obj);                
  465.   
  466.   if (PlayerVerified(myVideo, serialPort) != -1)            /* Sets up serial line for communicating with the device */
  467.     if (SetSerialLine(myVideo->DevConfig, serialPort))
  468.       return myVideo;
  469.     else
  470.       return NULL;
  471.   else
  472.     return NULL;
  473. }                                    /* end function DevInit */
  474.  
  475.  
  476.  
  477. /* WRITING NEW APPLICATIONS... 
  478.  * Optional : Replace the code within DisplayError() if a different 
  479.  * error notification function is desired.
  480.  *
  481.  * DO NOT remove the function DisplayError().
  482.  * 
  483.  * DisplayError() is useful in displaying errors other than those dealing
  484.  * with the device.
  485.  */
  486.  
  487. /* WRITING NEW DRIVERS...
  488.  * IMPORTANT : 
  489.  * Video drivers should be written such that any detectable error
  490.  * is decoded into English and placed into at most 2 strings. Then the
  491.  * driver is responsible for calling DisplayError() which displays the
  492.  * errors appropriately to the user.
  493.  */
  494.  
  495. /* DisplayError takes 2 strings that explain the error condition encountered.
  496.  */
  497. void
  498. DisplayError(char* errorMsg1,
  499.          char* errorMsg2)
  500. {
  501.   notice_prompt(vcrEdit_window1->window1, NULL,
  502.         NOTICE_MESSAGE_STRINGS,
  503.         errorMsg1,
  504.         errorMsg2,
  505.         NULL,
  506.         NOTICE_BUTTON,    "OK", 100,
  507.         NULL);
  508. }
  509.  
  510.  
  511. /* Display choice message */
  512. int
  513. DisplayChoice(char* msg1,
  514.           char* msg2,
  515.           char* r1,
  516.           char* r2)
  517. {
  518.   int result = notice_prompt(vcrEdit_window1->window1, NULL,
  519.                  NOTICE_MESSAGE_STRINGS,
  520.                  msg1, msg2,
  521.                  NULL,
  522.                  NOTICE_BUTTON_YES, r1,
  523.                  NOTICE_BUTTON_NO, r2, 
  524.                  NULL);
  525.   return result;
  526.   
  527. }
  528.  
  529.  
  530. void
  531. PrintDiagnostics(char* msg)
  532. {
  533.   if (diagMode == Yes)
  534.     fprintf(stderr, "%s", msg);
  535. }
  536.  
  537.  
  538. static int (*callbackProc)(int);                    /* Pointer to function called when asynch read is needed */
  539.  
  540.     
  541. Notify_value MyAsyncCallback(Notify_client    client,
  542.                  int        fd)
  543. {
  544.   return((*callbackProc) (fd));
  545. }                                    /* end function MyAsyncCallback */
  546.  
  547.  
  548.  
  549. void 
  550. SetAsynchReadFunction(int    (*callback)(int),
  551.               int    fd,
  552.               int    onOrOff)
  553. {
  554.   /* Code here would use the callback function provided to be
  555.      called when input occurred on the file descriptor of "theObject".
  556.      For XView, the code might be this:
  557.      */
  558.   callbackProc = callback;
  559.   
  560.   if (onOrOff == FeatureOn)
  561.     notify_set_input_func((Notify_client) AppClient, 
  562.               MyAsyncCallback, fd);
  563.   else
  564.     notify_set_input_func((Notify_client) AppClient,
  565.               NOTIFY_FUNC_NULL, fd);            /* Turn off automatic read */
  566. }                                    /* end function SetAsynchReadFunction */
  567.